home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / X11R4 / cmds / X / ddx / dec / qdss / libtl / tlsetspan.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-26  |  4.6 KB  |  188 lines

  1. /***********************************************************
  2. Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
  3. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  4.  
  5.                         All Rights Reserved
  6.  
  7. Permission to use, copy, modify, and distribute this software and its 
  8. documentation for any purpose and without fee is hereby granted, 
  9. provided that the above copyright notice appear in all copies and that
  10. both that copyright notice and this permission notice appear in 
  11. supporting documentation, and that the names of Digital or MIT not be
  12. used in advertising or publicity pertaining to distribution of the
  13. software without specific, written prior permission.  
  14.  
  15. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  16. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  17. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  18. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  19. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  20. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21. SOFTWARE.
  22.  
  23. ******************************************************************/
  24.  
  25. /*
  26.  *  setspan.c
  27.  *
  28.  *  written by Kelleher, july 1986
  29.  *  (adapted from code written by drewry)
  30.  *
  31.  *  Set a span (type determined by srcpixtype) in the framebuffer
  32.  *  to the values given.
  33.  *
  34.  *  NOTES
  35.  *  this will work only if each channel has <8K pixels
  36.  */
  37.  
  38. #include <sys/types.h>
  39. #include <stdio.h>    /* debug */
  40.  
  41. #include "X.h"
  42. #include "windowstr.h"
  43. #include "regionstr.h"
  44. #include "pixmap.h"
  45. #include "gcstruct.h"
  46. #include "dixstruct.h"
  47.  
  48. #include "Xproto.h"
  49. #include "Xprotostr.h"
  50. #include "mi.h"
  51. #include "Xmd.h"
  52.  
  53. /*
  54.  * driver headers
  55.  */
  56. #include "Ultrix2.0inc.h"
  57. #include <vaxuba/qduser.h>
  58. #include <vaxuba/qdioctl.h>
  59. #include <vaxuba/qdreg.h>
  60.  
  61. #include    "tl.h"
  62. #include "qd.h"
  63. #include "qdgc.h"
  64. #include "tltemplabels.h"
  65.  
  66. extern    int    Nchannels;
  67.  
  68. #define    pixelsize    (1)
  69.  
  70. tlsetspans(pDraw, pGC, pcolorInit, pPoint, pWidth, n, fSorted)
  71.     DrawablePtr pDraw;
  72.     GCPtr    pGC;
  73.     unsigned char *pcolorInit;
  74.     DDXPointPtr pPoint;
  75.     int *pWidth;
  76.     int n;
  77.     int fSorted;
  78. {
  79.     int        x = pPoint->x;
  80.     int        y = pPoint->y;
  81.     int        width = *pWidth;
  82.     register unsigned short *p;
  83.     register int npix;
  84. #if NPLANES==24
  85.     register int zblock;
  86. #endif
  87.     int        i;
  88.     RegionPtr    pSaveGCclip = QDGC_COMPOSITE_CLIP(pGC);
  89.     int        nclip = REGION_NUM_RECTS(pSaveGCclip);
  90.     register BoxPtr    pclip = REGION_RECTS(pSaveGCclip);
  91.     register unsigned char    *pcolor;
  92.  
  93.     extern struct DMAreq *DMArequest;
  94.     extern u_short *DMAbuf;
  95.  
  96.     if ( width == 0)
  97.     return;
  98.     if ( width > MAXDGAWORDS)
  99.     {
  100.     ErrorF( "tlsetspans: width > MAXDGAWORDS\n");
  101.     width = MAXDGAWORDS;
  102.     }
  103.  
  104.     SETTRANSLATEPOINT(pGC->lastWinOrg.x, pGC->lastWinOrg.y);
  105.  
  106.     /*
  107.      *  Just set up some state and fall through to code below
  108.      *  for all RGB pixel data.  The state we are interested in is
  109.      *  the number of zblocks, and the zblock identifiers, as well
  110.      *  as the size of pixel data (for bopping through the array).
  111.      *  Z buffer data is handled seperately.
  112.      */
  113.  
  114.     while (nclip-- > 0) {
  115.     Need_dma(8);
  116.     *p++ = JMPT_SET_MASKED_ALU;
  117.     *p++ = pGC->planemask;
  118.     *p++ = umtable[pGC->alu];
  119.     *p++ = JMPT_SETCLIP;
  120.     /* don't need to mask with 0x3fff, since clipped to screen size */
  121.     *p++ = pclip->x1;
  122.     *p++ = pclip->x2;
  123.     *p++ = pclip->y1;
  124.     *p++ = pclip->y2;
  125.     Confirm_dma();
  126.  
  127. #if NPLANES==24
  128.     for (i=0, pcolor = pcolorInit; i<Nchannels; i++) {
  129.         switch (i)
  130.         {
  131.         case 0:
  132.                 zblock = ZRED;
  133.             break;
  134.         case 1:
  135.                 zblock = ZGREEN;
  136.             break;
  137.         case 2:
  138.                 zblock = ZBLUE;
  139.             break;
  140.         }
  141.         /*     24--all red, all green, all blue; NOT r/g/b,r/g/b,r/g/b,... */
  142.         Need_dma(11 + width);    /* planes+initptob */
  143.         *p++ = JMPT_SETRGBPLANEMASK;
  144.         switch(zblock) {
  145.           case ZGREEN:
  146.         *p++ = 0x00;
  147.         *p++ = GREEN(pGC->planemask);
  148.         *p++ = 0x00;
  149.         break;
  150.          case ZRED:
  151.         *p++ = RED(pGC->planemask);
  152.         *p++ = 0x00;
  153.         *p++ = 0x00;
  154.         break;
  155.          case ZBLUE:
  156.         *p++ = 0x00;
  157.         *p++ = 0x00;
  158.         *p++ = BLUE(pGC->planemask);
  159.         break;
  160.         }
  161. #else
  162.         {
  163.         pcolor = pcolorInit;
  164.         /*     8--all grey (actually green) */
  165.         Need_dma(7 + width);    /* planes+initptob */
  166. #endif
  167.         *p++ = JMPT_INITPTOB;
  168.         *p++ = x & 0x3fff;
  169.         *p++ = y & 0x3fff;
  170.         *p++ = width &0x3fff;
  171.         *p++ = 1;
  172.  
  173. #if NPLANES==24
  174.         *p++ = PTBZ | zblock;
  175. #else
  176.         *p++ = PTBZ | 0;
  177. #endif
  178.         /* DGA magic bit pattern for PTB */
  179.         *p++ = 0x6000 |(0x1fff & -width);
  180.         npix = width;
  181.         while (npix--)
  182.         *p++ = *pcolor++;
  183.         Confirm_dma ();
  184.     }
  185.     pclip++;
  186.     }
  187. }
  188.